001 /** 002 * Created by IntelliJ IDEA. 003 * User: Wei Wang 004 * Date: Feb 14, 2003 005 * Time: 9:35:11 PM 006 */ 007 008 package EVolve.util.painters.shapes; 009 010 import java.awt.*; 011 012 public class Box extends Shape{ 013 private int width, height; 014 015 public Box(long entity_type,long entity_id, int width, int height) { 016 super(entity_type,entity_id); 017 this.entity_type = entity_type; 018 this.width = width; 019 this.height = height; 020 } 021 022 public String getName() { 023 return "Box"; 024 } 025 026 public void draw(Graphics2D g) { 027 if (color != null) g.setColor(color); 028 g.drawRect(x,y,width,height); 029 030 if (consumerMap == null) return; 031 032 drawArrows(g); 033 } 034 035 public void fill(Graphics2D g) { 036 if (color != null) g.fillRect(x,y,width,height); 037 } 038 039 public boolean insideShape(int x, int y) { 040 if ((x<=this.x+width) && (x>=this.x) && 041 (y<=this.y+height) && (y>=this.y)) 042 return true; 043 return false; 044 } 045 046 public int getWidth() { 047 return width; 048 } 049 050 public int getHeight() { 051 return height; 052 } 053 054 public void setSize(int width, int height) { 055 this.width = width; 056 this.height = height; 057 } 058 }